Skip to content

Motor test tests#1055

Merged
amilcarlucas merged 3 commits into
masterfrom
motor_test_tests
Nov 24, 2025
Merged

Motor test tests#1055
amilcarlucas merged 3 commits into
masterfrom
motor_test_tests

Conversation

@amilcarlucas

Copy link
Copy Markdown
Collaborator

No description provided.

Refactor the code for tesability
Tests for the configuration-step processor were added/updated as part of the same change.
Copilot AI review requested due to automatic review settings November 24, 2025 20:23

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds comprehensive test coverage for the motor test functionality, bringing both the frontend (Tkinter) and data model test files from omitted to fully tested. The tests follow a behavior-driven development (BDD) approach with extensive use of Given-When-Then documentation patterns. Additionally, the PR includes refactoring of the motor test code to improve testability and fix a state leakage bug in the configuration step processor.

Key Changes

  • New comprehensive test suite for frontend_tkinter_motor_test.py covering UI interactions, status callbacks, and error handling with 907 lines of BDD-style tests
  • Extensive test expansion for data_model_motor_test.py adding ~1200 lines of tests covering settings validation, frame selection workflows, battery feedback, parameter guards, and motor execution workflows
  • Code refactoring to extract reusable methods (run_single_motor_test, run_all_motors_test, etc.) and introduce MotorStatusEvent enum for better separation of concerns
  • Bug fix in configuration step processor preventing helper variable leakage between steps

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tests/test_frontend_tkinter_motor_test.py New comprehensive test suite (907 lines) covering view initialization, widget interactions, motor test workflows, keyboard shortcuts, error handling, and CLI argument parsing
tests/test_data_model_motor_test.py Added 1200+ lines of tests for settings validation, frame selection, battery status, parameter guards, and motor execution workflows with extensive edge case coverage
tests/test_data_model_configuration_step.py Added test to verify connection renaming state doesn't leak between configuration steps
ardupilot_methodic_configurator/frontend_tkinter_motor_test.py Refactored motor test methods to use new model API (run_*_test methods), extracted _ensure_first_test_confirmation and _handle_status_event helpers, simplified motor grid update logic
ardupilot_methodic_configurator/data_model_motor_test.py Added MotorStatusEvent enum and callback type, introduced run_*_test convenience methods, added set_motor_spin_arm_value/set_motor_spin_min_value with validation, implemented first-test warning acknowledgement tracking, added update_frame_type_by_key method
ardupilot_methodic_configurator/data_model_configuration_step.py Fixed helper variable leakage by using variables.copy() and explicitly removing new_connection_prefix when not used in current step
.coveragerc Removed frontend_tkinter_motor_test.py from omit list to track coverage now that comprehensive tests exist
Comments suppressed due to low confidence (2)

tests/test_frontend_tkinter_motor_test.py:18

  • Import of 'Any' is not used.
from typing import TYPE_CHECKING, Any, Callable, cast  # pylint: disable=unused-import

tests/test_frontend_tkinter_motor_test.py:30

  • Import of 'MotorTestDataModel' is not used.
from ardupilot_methodic_configurator.data_model_motor_test import (  # pylint: disable=unused-import
    MotorTestDataModel,
    MotorTestExecutionError,
    MotorTestSafetyError,
    ParameterError,
    ValidationError,
)

Comment on lines +24 to +30
from ardupilot_methodic_configurator.data_model_motor_test import ( # pylint: disable=unused-import
MotorTestDataModel,
MotorTestExecutionError,
MotorTestSafetyError,
ParameterError,
ValidationError,
)

Copilot AI Nov 24, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The # pylint: disable=unused-import comments on lines 18 and 24 suggest these imports may not be used in the test file. While some imports might be used only in type annotations (like TYPE_CHECKING context), others like MotorTestDataModel, MotorTestExecutionError, etc. should be actively used in tests. Consider removing genuinely unused imports or using them appropriately.

Suggested change
from ardupilot_methodic_configurator.data_model_motor_test import ( # pylint: disable=unused-import
MotorTestDataModel,
MotorTestExecutionError,
MotorTestSafetyError,
ParameterError,
ValidationError,
)

Copilot uses AI. Check for mistakes.

import pytest

import ardupilot_methodic_configurator.frontend_tkinter_motor_test as motor_test_module

Copilot AI Nov 24, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Module 'ardupilot_methodic_configurator.frontend_tkinter_motor_test' is imported with both 'import' and 'import from'.

Copilot uses AI. Check for mistakes.
@github-actions

Copy link
Copy Markdown
Contributor

☂️ Python Coverage

current status: ✅

Overall Coverage

Lines Covered Coverage Threshold Status
10151 9069 89% 80% 🟢

New Files

No new covered files...

Modified Files

File Coverage Status
ardupilot_methodic_configurator/data_model_configuration_step.py 100% 🟢
ardupilot_methodic_configurator/data_model_motor_test.py 100% 🟢
ardupilot_methodic_configurator/frontend_tkinter_motor_test.py 90% 🟢
TOTAL 97% 🟢

updated for commit: e9a3f75 by action🐍

@github-actions

Copy link
Copy Markdown
Contributor

Test Results

    3 files  ±  0      3 suites  ±0   30m 48s ⏱️ -13s
2 428 tests + 96  2 138 ✅ + 96   2 💤 ± 0   50 ❌ ±0  238 🔥 ±0 
7 284 runs  +288  6 612 ✅ +246  96 💤 +42  100 ❌ ±0  476 🔥 ±0 

For more details on these failures and errors, see this check.

Results for commit e9a3f75. ± Comparison against base commit 90505e5.

This pull request removes 1 and adds 97 tests. Note that renamed tests count towards both.
tests.test_data_model_motor_test.TestMotorTestDataModelSettingsPersistence ‑ test_set_test_throttle_pct_succeeds_with_valid_value
tests.test_data_model_configuration_step.TestConfigurationStepProcessorConnectionRenaming ‑ test_connection_renaming_state_does_not_leak_between_steps
tests.test_data_model_motor_test.TestMotorTestDataModelBatteryFeedback ‑ test_battery_safety_messaging_highlights_reason
tests.test_data_model_motor_test.TestMotorTestDataModelBatteryFeedback ‑ test_user_gets_color_coded_voltage_feedback
tests.test_data_model_motor_test.TestMotorTestDataModelBatteryFeedback ‑ test_user_reads_battery_display_text_feedback
tests.test_data_model_motor_test.TestMotorTestDataModelBatteryFeedback ‑ test_user_sees_cached_battery_status_after_initial_request
tests.test_data_model_motor_test.TestMotorTestDataModelFrameConfiguration ‑ test_frame_configuration_update_handles_missing_layouts
tests.test_data_model_motor_test.TestMotorTestDataModelFrameConfiguration ‑ test_frame_configuration_update_skips_recalc_when_data_missing
tests.test_data_model_motor_test.TestMotorTestDataModelFrameOptionsAdvanced ‑ test_frame_options_fallback_handles_missing_frame_type_section
tests.test_data_model_motor_test.TestMotorTestDataModelFrameOptionsAdvanced ‑ test_frame_options_fallback_skips_invalid_doc_entries
tests.test_data_model_motor_test.TestMotorTestDataModelFrameOptionsAdvanced ‑ test_frame_options_fallback_uses_doc_dict_values
…

@amilcarlucas amilcarlucas merged commit 5b6b8c6 into master Nov 24, 2025
32 of 36 checks passed
@amilcarlucas amilcarlucas deleted the motor_test_tests branch November 24, 2025 20:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants